package com.collectplus.express.menu;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.collectplus.express.R;
import com.collectplus.express.model.OrderItemBean;

import droid.frame.activity.base.BaseAdapterExt;
/**
 * 我的订单
 * @author coffee<br>2015-6-18下午1:44:41
 */
public class OrderListAdapter extends BaseAdapterExt<OrderItemBean> {

	private SimpleDateFormat sdf;

	public OrderListAdapter(Activity context, ArrayList<OrderItemBean> items) {
		super(items, context);
		sdf = new SimpleDateFormat("yyyy/MM/dd", Locale.getDefault());
	}

	 
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.order_list_item, parent, false);
			viewHolder.mName = (TextView) convertView.findViewById(R.id.item_history_name_tv);
			viewHolder.mMobile = (TextView) convertView.findViewById(R.id.item_history_mobile_tv);
			viewHolder.mRouter = (TextView) convertView.findViewById(R.id.item_history_router_tv);
			viewHolder.mDate = (TextView) convertView.findViewById(R.id.item_history_date_tv);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		//
		OrderItemBean item = getItem(position);
		viewHolder.mName.setText(item.getReceiverName());
		viewHolder.mMobile.setText(item.getReceiverPhone());
		viewHolder.mRouter.setText(item.getCurrentRouter());
		String date = sdf.format(new Date(item.getCreateTime()));
		viewHolder.mDate.setText(date);
		

		return convertView;
	}

	private class ViewHolder {
		private TextView mName;
		private TextView mMobile;
		private TextView mRouter;
		private TextView mDate;
	}

}
